cmake_minimum_required(VERSION 3.10)
project(inode_query LANGUAGES C)

add_custom_target(inode_query_src
    SOURCES
    dkms/inode_query.c
)

# 用户空间程序构建
add_executable(inode_query_user user/inode_query_user.c)
#install(TARGETS inode_query_user DESTINATION /usr/bin)

# DKMS模块安装配置
set(DKMS_MODULE_NAME "inode_query")
set(DKMS_MODULE_VERSION "1.0.0")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dkms/dkms.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/dkms/dkms.conf @ONLY)

install(DIRECTORY dkms/
        DESTINATION /usr/src/${DKMS_MODULE_NAME}-${DKMS_MODULE_VERSION}
        USE_SOURCE_PERMISSIONS)

# 内核模块默认加载配置
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/inode_query.conf
	DESTINATION /etc/modules-load.d
	PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
